<template>
  <div class="index-container">
    <el-row :gutter="20">
      <el-col :xs="24" :sm="24" :md="12" :lg="6" :xl="6">
        <el-card  class="box-card">
          <div slot="header">
            <span>是否受理接单</span>
          </div>
          <div>
           <el-switch
              v-model="receiveOrder.configValue"
              active-color="#13ce66"
              inactive-color="#ff4949"
              active-value="1"
              active-text="受理"
              inactive-value="0"
              inactive-text="不受理"
              @change="changeConfig">
            </el-switch>
          </div>
        </el-card>
      </el-col>
    </el-row>
  </div>
</template>

<script>
import {
    doGet,
    doEdit,
  } from '@/api/configManagement'
export default {
  name: 'Index',
  components: {
  },
  data() {
    return {
      receiveOrder:{
        id:0,
        configKey:'RECEIVE_ORDER',
        configValue:'0'
      }
    }
  },
  created() {
    this.fetchData()
  },
  methods: {
    async fetchData() {
      let res = await doGet(this.receiveOrder.configKey)
      this.receiveOrder.id = res.id
      this.receiveOrder.configValue = res.configValue || '0'
    },
    async changeConfig(){
      await doEdit(this.receiveOrder)
    }
  }
}
</script>
<style lang="scss" scoped>
::v-deep .el-card__header {
  background-color: #F2F6FC;
}
</style>
